<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <script src="https://cdn.tailwindcss.com"></script>
    <script>
      tailwind.config = {
        darkMode: 'class',
      }
    </script>
    <link rel="stylesheet" href="./style.css" />
    <title>06_CSS反向悬停</title>
  </head>
  <body class="box-border select-none dark:bg-[#363433] bg-[#f4f4f4] duration-300">
    <div class="switch fixed w-[50px] h-[25px] top-[30px] right-[30px] align-middle">
      <input
        type="checkbox"
        name="toggle"
        id="toggle"
        class="absolute block w-5 h-5 m-[3px] rounded-full border-2 border-solid border-gray-300 cursor-pointer bg-white appearance-none z-10 checked:right-0 checked:border-[#68d391]"
      />
      <label
        for="toggle"
        class="toggleLabel absolute block h-[25px] w-full overflow-hidden rounded-[25px] border-4 border-solid border-slate-300 bg-slate-300 cursor-pointer"
      ></label>
    </div>
    <ul class="absolute top-1/2 left-1/2 -translate-x-1/2 -translate-y-1/2 grid grid-flow-col">
      <li>
        <a
          href="#"
          class="relative flex justify-center items-center w-[150px] h-[80px] text-center leading-[80px] border border-solid border-[#363433] dark:border-[#f4f4f4] text-[#363433] dark:text-[#f4f4f4] font-medium -z-0 before:absolute before:top-0 before:left-0 before:w-full before:h-full before:-z-10 before:origin-right before:scale-x-0 before:duration-500 before:ease-in-out hover:before:origin-left hover:before:scale-x-100 hover:text-white"
        >
          <svg
            xmlns="http://www.w3.org/2000/svg"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            version="1.1"
            width="20px"
            height="20px"
            viewBox="0 0 400 400"
            class="mr-2"
          >
            <image id="image0" width="400" height="400" href="../assets/icons/xinlang.png" />
          </svg>
          微博
        </a>
      </li>
      <li>
        <a
          href="#"
          class="relative flex justify-center items-center w-[150px] h-[80px] text-center leading-[80px] border border-solid border-[#363433] dark:border-[#f4f4f4] text-[#363433] dark:text-[#f4f4f4] font-medium -z-0 before:absolute before:top-0 before:left-0 before:w-full before:h-full before:-z-10 before:scale-x-0 before:origin-right before:duration-500 before:ease-in-out hover:before:scale-x-100 hover:before:origin-left hover:text-white"
        >
          <svg
            xmlns="http://www.w3.org/2000/svg"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            version="1.1"
            width="20px"
            height="20px"
            viewBox="0 0 400 400"
            class="mr-2"
          >
            <image id="image0" width="400" height="400" href="../assets/icons/bilibili.png" />
          </svg>
          BiLibili
        </a>
      </li>
      <li>
        <a
          href="#"
          class="relative flex justify-center items-center w-[150px] h-[80px] text-center leading-[80px] border border-solid border-[#363433] dark:border-[#f4f4f4] text-[#363433] dark:text-[#f4f4f4] font-medium -z-0 before:absolute before:top-0 before:left-0 before:w-full before:h-full before:-z-10 before:scale-x-0 before:origin-right before:duration-500 before:ease-in-out hover:before:scale-x-100 hover:before:origin-left hover:text-[#363433] dark:hover:text-[#363433]"
        >
          <svg
            xmlns="http://www.w3.org/2000/svg"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            version="1.1"
            width="20px"
            height="20px"
            viewBox="0 0 400 400"
            class="mr-2"
          >
            <image id="image0" width="400" height="400" href="../assets/icons/toutiao.png" />
          </svg>
          今日头条
        </a>
      </li>
      <li>
        <a
          href="#"
          class="relative flex justify-center items-center w-[150px] h-[80px] text-center leading-[80px] border border-solid border-[#363433] dark:border-[#f4f4f4] text-[#363433] dark:text-[#f4f4f4] font-medium -z-0 before:absolute before:top-0 before:left-0 before:w-full before:h-full before:-z-10 before:scale-x-0 before:origin-right before:duration-500 before:ease-in-out hover:before:scale-x-100 hover:before:origin-left hover:text-white"
        >
          <svg
            xmlns="http://www.w3.org/2000/svg"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            version="1.1"
            width="20px"
            height="20px"
            viewBox="0 0 400 400"
            class="mr-2"
          >
            <image width="400" height="400" href="../assets/icons/boos.png" />
          </svg>
          Boss直聘
        </a>
      </li>
      <li>
        <a
          href="#"
          class="relative flex justify-center items-center w-[150px] h-[80px] text-center leading-[80px] border border-solid border-[#363433] dark:border-[#f4f4f4] text-[#363433] dark:text-[#f4f4f4] font-medium -z-0 before:absolute before:top-0 before:left-0 before:w-full before:h-full before:-z-10 before:scale-x-0 before:origin-right before:duration-500 before:ease-in-out hover:before:scale-x-100 hover:before:origin-left hover:text-white"
        >
          <svg
            xmlns="http://www.w3.org/2000/svg"
            xmlns:xlink="http://www.w3.org/1999/xlink"
            version="1.1"
            width="20px"
            height="20px"
            viewBox="0 0 400 400"
            class="mr-2"
          >
            <image width="400" height="400" href="../assets/icons/douyin.png" />
          </svg>
          抖音
        </a>
      </li>
    </ul>
    <script>
      const input = document.querySelector('#toggle')
      const text = document.querySelectorAll('ul>li>a')
      const html = document.documentElement
      input.addEventListener('change', function () {
        if (input.checked) {
          html.classList.add('dark')
        } else {
          html.classList.remove('dark')
        }
      })
    </script>
    <script>
      // 判断是否为夜间模式
      const isDark = window.matchMedia('(prefers-color-scheme: dark)').matches
      if (isDark) {
        input.checked = true
      }
    </script>
  </body>
</html>
